#!/bin/sh
#
# While it's obviously quite impossible to support and test every single
# distribution, this script enables easy checking of the most common standard
# distributions at least.

set -eu

build_in_docker=$(dirname $0)/build-in-docker

build() {
    local name=$1
    local cc=$2
    local cxx=$3
    local test_cc=$4
    shift 4
    local cmake_params="$*"
    if command -v >/dev/null ccache; then
        cmake_params="${cmake_params} -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache"
    fi
    echo "Build in Docker: $name CC=$cc CXX=$cxx TEST_CC=$test_cc CMAKE_PARAMS=\"$*\""
    ASM=$cc CC=$cc CXX=$cxx TEST_CC=$test_cc CMAKE_PARAMS="${cmake_params}" $build_in_docker $name
}

#     NAME         CC     CXX     TEST_CC CMAKE_PARAMS

build debian-11    gcc    g++     gcc
build debian-11    clang  clang++ clang

build ubuntu-18.04 gcc-9  g++-9   gcc
build ubuntu-18.04 clang  clang++ clang

build ubuntu-20.04 gcc    g++     gcc
build ubuntu-20.04 clang  clang++ clang

build ubuntu-22.04 gcc    g++     gcc
build ubuntu-22.04 clang  clang++ clang

build ubuntu-22.04 gcc-12 g++-12  gcc
build ubuntu-22.04 clang  clang++ clang

build centos-7     gcc    g++     gcc     -DHIREDIS_FROM_INTERNET=ON
build centos-7     gcc    g++     clang   -DHIREDIS_FROM_INTERNET=ON

build fedora-36    gcc    g++     gcc
build fedora-36    clang  clang++ clang

build alpine-3.11  gcc    g++     gcc
build alpine-3.11  gcc    g++     clang

build alpine-3.15  gcc    g++     gcc
build alpine-3.15  clang  clang++ clang
